<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%if(session.getAttribute("uname")!=null){
    System.out.println("有登录信息直接登录");
    response.sendRedirect("chat.jsp");
}%>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css" />
</head>
<body onload="checkErr();">
<div class="container">
    <div class="col-md-3"></div>
    <div class="aaa col-md-6" style="margin-top: 30px">
        <form method="post" action="chat.jsp" name="myform" onsubmit="return checkInfo();">
            <div class="form-group">
                <label for="exampleInputName2">Username</label>
                <input type="text" class="form-control" name="uname" id="exampleInputName2" placeholder="Username">
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">Password</label>
                <input type="password" class="form-control" name="pword" id="exampleInputPassword1" placeholder="Password">
            </div>
            <button type="submit" class="btn btn-default">登入</button>
        </form>
    </div>
    <div class="col-md-3"></div>
</div>
<script>
    function checkInfo(){
        var uname = document.forms['myform']['uname'].value;
        var pword = document.forms['myform']['pword'].value;
        if(uname == '' || pword == ''){
            alert('用户名不能为空');
            return false;
        }
        return true;
    }
    function checkErr(){
        var uname = "<%=request.getParameter("e")%>";
        if(uname == '1'){
            alert("密码错误");
        }
    }
</script>
</body>
</html>